From b049bd59c8a0d1408fb0e124a2a1e18714f45c4e Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Wed, 10 Aug 2005 14:30:49 +0000 Subject: [PATCH] type system cleanup --- ChangeLog | 31 ++++++++++++++++++++++--- babl/Makefile-mini | 5 ++-- babl/babl-classes.c | 2 ++ babl/babl-classes.h | 49 +++++++++++++++++++--------------------- babl/babl-component.c | 23 ++++++++++--------- babl/babl-conversion.c | 36 ++++++++++++++--------------- babl/babl-db.h | 2 +- babl/babl-fish.c | 25 ++++++++++---------- babl/babl-format.c | 35 ++++++++++++++-------------- babl/babl-image.c | 36 ++++++++++++++--------------- babl/babl-internal.c | 2 ++ babl/babl-introspect.c | 10 ++++---- babl/babl-model.c | 27 +++++++++++----------- babl/babl-pixel-format.c | 35 ++++++++++++++-------------- babl/babl-sampling.c | 2 +- babl/babl-sanity.c | 2 +- babl/babl-type.c | 33 +++++---------------------- tests/Makefile.am | 2 ++ 18 files changed, 183 insertions(+), 174 deletions(-) diff --git a/ChangeLog b/ChangeLog index 309605f..738bd36 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,29 @@ -2005-09-09 Øyvind Kolås +2005-08-09 Øyvind Kolås + + * babl/Makefile-mini: CFLAGS = -Werror -Wall .... + * babl/babl-classes.[ch]: BablPixelFormat removed unused pointers + to lists of conversions. Added BablReferenceFish. Renamed kind/ + instance.type to class_type/instance.class_type. Removed mostly + unused macro's and expanded them in source + + * babl/babl-component.c + * babl/babl-conversion.c + * babl/babl-db.h + * babl/babl-fish.c + * babl/babl-image.c + * babl/babl-introspect.c + * babl/babl-model.c + * babl/babl-pixel-format.c + * babl/babl-sampling.c + + * babl/babl-type.c: removed switch statement since all enums are + handled equally. + + * babl/tests/Makefile.am: added nop and introspect to TESTS, not + actual tests yet, but at least a segfault will cause make check to + fail. + +2005-08-09 Øyvind Kolås * autogen.sh: make autogen also run make * babl/babl-classes.h: added define macro usable for sampling and @@ -6,11 +31,11 @@ * babl/babl-fish.[ch]: cleanup of stub class * babl/babl-sampling.h: simplification of header using a define. -2005-09-09 Øyvind Kolås +2005-08-09 Øyvind Kolås * babl/babl-conversion.c: indentation cleanup. -2005-09-09 Øyvind Kolås +2005-08-09 Øyvind Kolås * babl/babl-ids: added BABL_LUMINANCE_GAMMA_2_2, BABL_LUMINANCE_MUL_ALPHA, BABL_GRAYSCALE_GAMMA_2_2, diff --git a/babl/Makefile-mini b/babl/Makefile-mini index ae4f71a..ea1d7fb 100644 --- a/babl/Makefile-mini +++ b/babl/Makefile-mini @@ -1,13 +1,14 @@ # This makeile is used for more rapid test compilations than # autofoo allows, it will not build a usable libray though. -default: clean all TARGETS = \ ../tests/nop \ ../tests/introspect -CFLAGS = -Wall -g -O1 -I./babl-base -I. -I.. +default: $(TARGETS) + +CFLAGS = -Wall -Werror -g -O1 -I./babl-base -I. -I.. BABL_OBJECTS= \ babl.o \ diff --git a/babl/babl-classes.c b/babl/babl-classes.c index f39350a..0d2e028 100644 --- a/babl/babl-classes.c +++ b/babl/babl-classes.c @@ -34,6 +34,8 @@ static const char *class_names[] = "BablConversionPixelFormatPlanar", "BablConversionPixelFormatPlanar", "BablFish", + "BablReferenceFish", + "BablImage", "BablCeiling" }; diff --git a/babl/babl-classes.h b/babl/babl-classes.h index 3b9fffe..6d69ea3 100644 --- a/babl/babl-classes.h +++ b/babl/babl-classes.h @@ -62,6 +62,7 @@ typedef enum { BABL_CONVERSION_PIXEL_FORMAT_PLANAR, BABL_FISH, + BABL_FISH_REFERENCE, BABL_IMAGE, BABL_SKY @@ -73,7 +74,7 @@ typedef enum { /* common header for any item inserted into database */ typedef struct { - BablClassType type; + BablClassType class_type; int id; /*< a numerical id, look at 'babl-ids.h' for the reserved ones */ char *name; /*< the name this type exists under */ @@ -167,8 +168,6 @@ typedef struct BablComponent **component; BablType **type; BablSampling **sampling; - BablConversion *to_conversions; - BablConversion *from_conversions; } BablPixelFormat; typedef struct @@ -188,35 +187,33 @@ typedef struct union Babl *destination; } BablFish; +typedef struct +{ + BablFish fish; + BablConversion *type_to_double; + BablConversion *model_to_rgba; + BablConversion *rgba_to_model; + BablConversion *double_to_type; +} BablReferenceFish; + typedef union { - BablClassType kind; - BablInstance instance; - BablType type; - BablSampling sampling; - BablComponent component; - BablModel model; - BablPixelFormat pixel_format; - BablConversion conversion; - BablFish fish; - BablImage image; + BablClassType class_type; + BablInstance instance; + BablType type; + BablSampling sampling; + BablComponent component; + BablModel model; + BablPixelFormat pixel_format; + BablConversion conversion; + BablFish fish; + BablReferenceFish reference_fish; + BablImage image; } Babl; -#define BABL_NAME(obj) (((Babl*)(obj))->instance.name) -#define BABL_INSTANCE_TYPE(obj) (((Babl*)(obj))->kind) - #define BABL_IS_BABL(obj)\ -(NULL==(obj)?0:BABL_CLASS_TYPE_IS_VALID(BABL_INSTANCE_TYPE(obj))) - -#define BABL_IS_OF_KIND(obj,kind) \ - (!BABL_IS_BABL(obj)?0:kind==BABL_INSTANCE_TYPE(obj)?1:0) - -#define BABL_IS_INSTANCE(obj) BABL_IS_OF_KIND(obj,BABL_TYPE) -#define BABL_IS_TYPE(obj) BABL_IS_OF_KIND(obj,BABL_TYPE) -#define BABL_IS_COMPONENT(obj) BABL_IS_OF_KIND(obj,BABL_COMPONENT) -#define BABL_IS_SAMPLING(obj) BABL_IS_OF_KIND(obj,BABL_SAMPLING) -#define BABL_IS_PIXEL_FORMAT(obj) BABL_IS_OF_KIND(obj,BABL_PIXEL_FORMAT) +(NULL==(obj)?0:BABL_CLASS_TYPE_IS_VALID(((Babl*)(obj))->class_type)) typedef int (*BablEachFunction) (Babl *entry, void *data); diff --git a/babl/babl-component.c b/babl/babl-component.c index f4180e2..a591f8e 100644 --- a/babl/babl-component.c +++ b/babl/babl-component.c @@ -42,17 +42,17 @@ component_new (const char *name, int chroma, int alpha) { - BablComponent *self; + Babl *self; - self = babl_calloc (sizeof (BablComponent), 1); - self->instance.type = BABL_COMPONENT; - self->instance.id = id; - self->instance.name = babl_strdup (name); - self->luma = luma; - self->chroma = chroma; - self->alpha = alpha; + self = babl_calloc (sizeof (BablComponent), 1); + self->class_type = BABL_COMPONENT; + self->instance.id = id; + self->instance.name = babl_strdup (name); + self->component.luma = luma; + self->component.chroma = chroma; + self->component.alpha = alpha; - return self; + return (BablComponent*) self; } BablComponent * @@ -79,7 +79,7 @@ babl_component_new (const char *name, { Babl *babl = (Babl*)arg; - switch (BABL_INSTANCE_TYPE (arg)) + switch (babl->class_type) { case BABL_TYPE: case BABL_INSTANCE: @@ -95,9 +95,10 @@ babl_component_new (const char *name, case BABL_CONVERSION_PIXEL_FORMAT: case BABL_CONVERSION_PIXEL_FORMAT_PLANAR: case BABL_FISH: + case BABL_FISH_REFERENCE: case BABL_IMAGE: babl_log ("%s(): %s unexpected", - __FUNCTION__, babl_class_name (babl->instance.type)); + __FUNCTION__, babl_class_name (babl->class_type)); break; case BABL_SKY: /* shut up compiler */ break; diff --git a/babl/babl-conversion.c b/babl/babl-conversion.c index 21cb746..f2385ff 100644 --- a/babl/babl-conversion.c +++ b/babl/babl-conversion.c @@ -43,23 +43,23 @@ conversion_new (const char *name, BablFuncPlanar planar, BablFuncPlanarBit planar_bit) { - BablConversion *self = NULL; + Babl *self = NULL; /* destination is of same type as source */ - switch (BABL_INSTANCE_TYPE (source)) + switch (source->class_type) { case BABL_TYPE: if (linear) { self = babl_calloc (sizeof (BablConversionType), 1); - self->instance.type = BABL_CONVERSION_TYPE; - self->function.linear = linear; + self->class_type = BABL_CONVERSION_TYPE; + self->conversion.function.linear = linear; } else if (planar) { self = babl_calloc (sizeof (BablConversionTypePlanar), 1); - self->instance.type = BABL_CONVERSION_TYPE_PLANAR; - self->function.planar = planar; + self->class_type = BABL_CONVERSION_TYPE_PLANAR; + self->conversion.function.planar = planar; } else if (planar_bit) { @@ -84,8 +84,8 @@ conversion_new (const char *name, else if (planar) { self = babl_calloc (sizeof (BablConversionModelPlanar), 1); - self->instance.type = BABL_CONVERSION_MODEL_PLANAR; - self->function.planar = planar; + self->class_type = BABL_CONVERSION_MODEL_PLANAR; + self->conversion.function.planar = planar; } else if (planar_bit) { @@ -98,14 +98,14 @@ conversion_new (const char *name, if (linear) { self = babl_calloc (sizeof (BablConversionPixelFormat), 1); - self->instance.type = BABL_CONVERSION_PIXEL_FORMAT; - self->function.linear = linear; + self->class_type = BABL_CONVERSION_PIXEL_FORMAT; + self->conversion.function.linear = linear; } else if (planar) { self = babl_calloc (sizeof (BablConversionPixelFormatPlanar), 1); - self->instance.type = BABL_CONVERSION_PIXEL_FORMAT_PLANAR; - self->function.planar = planar; + self->class_type = BABL_CONVERSION_PIXEL_FORMAT_PLANAR; + self->conversion.function.planar = planar; } else if (planar_bit) { @@ -122,12 +122,12 @@ conversion_new (const char *name, return NULL; } - self->instance.id = id; - self->instance.name = babl_strdup (name); - self->source = (union Babl*)source; - self->destination = (union Babl*)destination; - self->time_cost = time_cost; - self->loss = loss; + self->instance.id = id; + self->instance.name = babl_strdup (name); + self->conversion.source = (union Babl*)source; + self->conversion.destination = (union Babl*)destination; + self->conversion.time_cost = time_cost; + self->conversion.loss = loss; babl_add_ptr_to_list ((void ***)&(source->type.from), self); babl_add_ptr_to_list ((void ***)&(destination->type.to), self); diff --git a/babl/babl-db.h b/babl/babl-db.h index 7b4b7e5..204a5bb 100644 --- a/babl/babl-db.h +++ b/babl/babl-db.h @@ -56,7 +56,7 @@ DB_DEF Babl * db_find (const char *name) const char *sample_type = "unknwon"; if (db[0]) - sample_type = babl_class_name (db[0]->instance.type); + sample_type = babl_class_name (db[0]->class_type); babl_log ("%s(\"%s\"): failed (query performed on a %s database)", __FUNCTION__, name, sample_type); } diff --git a/babl/babl-fish.c b/babl/babl-fish.c index b0a3a30..e4be9d8 100644 --- a/babl/babl-fish.c +++ b/babl/babl-fish.c @@ -36,26 +36,25 @@ babl_fish_new (const char *name, Babl *source, Babl *destination) { - BablFish *self = NULL; + Babl *self = NULL; - self = babl_calloc (sizeof (BablFish), 1); - self->instance.type = BABL_FISH; + assert (BABL_IS_BABL (source)); + assert (BABL_IS_BABL (destination)); - self->instance.id = 0; - self->instance.name = "Fishy"; - self->source = (union Babl*)source; - self->destination = (union Babl*)destination; + self = babl_calloc (sizeof (BablFish), 1); + self->class_type = BABL_FISH; + self->instance.id = 0; + self->instance.name = "Fishy"; + self->fish.source = (union Babl*)source; + self->fish.destination = (union Babl*)destination; - assert (BABL_IS_BABL (self->source)); - assert (BABL_IS_BABL (self->destination)); - - if ((BablFish*) db_insert ( (Babl*)self) == self) + if (db_insert (self) == self) { - return self; + return (BablFish*)self; } else { - each_babl_fish_destroy ( (Babl*)self, NULL); + each_babl_fish_destroy (self, NULL); return NULL; } diff --git a/babl/babl-format.c b/babl/babl-format.c index 226125c..c84536c 100644 --- a/babl/babl-format.c +++ b/babl/babl-format.c @@ -52,33 +52,33 @@ pixel_format_new (const char *name, BablSampling **band_sampling, BablType **band_type) { - BablPixelFormat *self; + Babl *self; int band; self = babl_calloc (sizeof (BablPixelFormat), 1); - self->instance.type = BABL_PIXEL_FORMAT; + self->class_type = BABL_PIXEL_FORMAT; self->instance.id = id; self->instance.name = babl_strdup (name); - self->bands = bands; - self->planar = planar; + self->pixel_format.bands = bands; + self->pixel_format.planar = planar; - self->component = babl_malloc (sizeof (BablComponent*) * (bands+1)); - self->type = babl_malloc (sizeof (BablType*) * (bands+1)); - self->sampling = babl_malloc (sizeof (BablSampling*) * (bands+1)); + self->pixel_format.component = babl_malloc (sizeof (BablComponent*) * (bands+1)); + self->pixel_format.type = babl_malloc (sizeof (BablType*) * (bands+1)); + self->pixel_format.sampling = babl_malloc (sizeof (BablSampling*) * (bands+1)); for (band=0; band < bands; band++) { - self->component[band] = band_component[band]; - self->type[band] = band_type[band]; - self->sampling[band] = band_sampling[band]; + self->pixel_format.component[band] = band_component[band]; + self->pixel_format.type[band] = band_type[band]; + self->pixel_format.sampling[band] = band_sampling[band]; } - self->component[band] = NULL; - self->type[band] = NULL; - self->sampling[band] = NULL; + self->pixel_format.component[band] = NULL; + self->pixel_format.type[band] = NULL; + self->pixel_format.sampling[band] = NULL; - return self; + return (BablPixelFormat*)self; } BablPixelFormat * @@ -112,7 +112,7 @@ babl_pixel_format_new (const char *name, { Babl *babl = (Babl*)arg; - switch (BABL_INSTANCE_TYPE (arg)) + switch (babl->class_type) { case BABL_TYPE: current_type = (BablType*) babl; @@ -135,7 +135,7 @@ babl_pixel_format_new (const char *name, case BABL_INSTANCE: case BABL_MODEL: babl_log ("%s(): %s not handled in pixel format yet", - __FUNCTION__, babl_class_name (babl->instance.type)); + __FUNCTION__, babl_class_name (babl->class_type)); break; case BABL_PIXEL_FORMAT: @@ -146,9 +146,10 @@ babl_pixel_format_new (const char *name, case BABL_CONVERSION_PIXEL_FORMAT: case BABL_CONVERSION_PIXEL_FORMAT_PLANAR: case BABL_FISH: + case BABL_FISH_REFERENCE: case BABL_IMAGE: babl_log ("%s(): %s unexpected", - __FUNCTION__, babl_class_name (babl->instance.type)); + __FUNCTION__, babl_class_name (babl->class_type)); break; case BABL_SKY: /* shut up compiler */ break; diff --git a/babl/babl-image.c b/babl/babl-image.c index 3edc962..6f398c7 100644 --- a/babl/babl-image.c +++ b/babl/babl-image.c @@ -50,35 +50,35 @@ image_new (int bands, int *pitch, int *stride) { - BablImage *self; + Babl *self; int band; self = babl_calloc (sizeof (BablImage), 1); - self->instance.type = BABL_IMAGE; + self->class_type = BABL_IMAGE; self->instance.id = 0; self->instance.name = "babl image"; - self->bands = bands; + self->image.bands = bands; - self->component = babl_malloc (sizeof (BablComponent*) * (bands+1)); - self->data = babl_malloc (sizeof (void*) * (bands+1)); - self->pitch = babl_malloc (sizeof (int) * (bands+1)); - self->stride = babl_malloc (sizeof (int) * (bands+1)); + self->image.component = babl_malloc (sizeof (BablComponent*) * (bands+1)); + self->image.data = babl_malloc (sizeof (void*) * (bands+1)); + self->image.pitch = babl_malloc (sizeof (int) * (bands+1)); + self->image.stride = babl_malloc (sizeof (int) * (bands+1)); for (band=0; band < bands; band++) { - self->component[band] = component[band]; - self->data[band] = data[band]; - self->pitch[band] = pitch[band]; - self->stride[band] = stride[band]; + self->image.component[band] = component[band]; + self->image.data[band] = data[band]; + self->image.pitch[band] = pitch[band]; + self->image.stride[band] = stride[band]; } - self->component[band] = NULL; - self->data[band] = NULL; - self->pitch[band] = 0; - self->stride[band] = 0; + self->image.component[band] = NULL; + self->image.data[band] = NULL; + self->image.pitch[band] = 0; + self->image.stride[band] = 0; - return self; + return (BablImage*) self; } BablImage * @@ -107,14 +107,14 @@ babl_image_new (void *first, { Babl *babl = (Babl*)arg; - if (babl->instance.type == BABL_COMPONENT) + if (babl->class_type == BABL_COMPONENT) { new_component = (BablComponent *)babl; } else { babl_log ("%s(): %s unexpected", - __FUNCTION__, babl_class_name (babl->instance.type)); + __FUNCTION__, babl_class_name (babl->class_type)); return NULL; } } diff --git a/babl/babl-internal.c b/babl/babl-internal.c index f39350a..0d2e028 100644 --- a/babl/babl-internal.c +++ b/babl/babl-internal.c @@ -34,6 +34,8 @@ static const char *class_names[] = "BablConversionPixelFormatPlanar", "BablConversionPixelFormatPlanar", "BablFish", + "BablReferenceFish", + "BablImage", "BablCeiling" }; diff --git a/babl/babl-introspect.c b/babl/babl-introspect.c index ca29cd9..6ab5b28 100644 --- a/babl/babl-introspect.c +++ b/babl/babl-introspect.c @@ -113,7 +113,7 @@ model_introspect (Babl *babl) for (i=0; i< babl->model.components; i++) { babl_log ("\t\tindex[%i] = '%s'", - i, BABL_NAME (babl->model.component[i])); + i, ((Babl*)babl->model.component[i])->instance.name ); } } @@ -144,8 +144,8 @@ pixel_format_introspect (Babl *babl) for (i=0; i< babl->pixel_format.bands; i++) { babl_log ("\t\tband[%i] type='%s' component='%s'", - i, BABL_NAME (babl->pixel_format.type[i]), - BABL_NAME (babl->pixel_format.component[i])); + i, ( (Babl*)(babl->pixel_format.type[i] ))->instance.name, + ( (Babl*)(babl->pixel_format.component[i]))->instance.name); } } @@ -156,8 +156,8 @@ each_introspect (Babl *babl, babl_log ("\t'%s'\t%i\t%s", babl->instance.name, babl->instance.id, - babl_class_name (babl->instance.type)); - switch (babl->instance.type) + babl_class_name (babl->class_type)); + switch (babl->class_type) { case BABL_TYPE: type_introspect (babl); diff --git a/babl/babl-model.c b/babl/babl-model.c index e1657ae..c957409 100644 --- a/babl/babl-model.c +++ b/babl/babl-model.c @@ -44,26 +44,24 @@ model_new (const char *name, int components, BablComponent **component) { - BablModel *self; - int i; + Babl *self; + int i; self = babl_calloc (sizeof (BablModel), 1); - self->instance.type = BABL_MODEL; - self->instance.id = id; - self->instance.name = babl_strdup (name); - - self->components = components; - - self->component = babl_malloc (sizeof (BablComponent*) * (components+1)); + self->class_type = BABL_MODEL; + self->instance.id = id; + self->instance.name = babl_strdup (name); + self->model.components = components; + self->model.component = babl_malloc (sizeof (BablComponent*) * (components+1)); for (i=0; i < components; i++) { - self->component[i] = component[i]; + self->model.component[i] = component[i]; } - self->component[i] = NULL; + self->model.component[i] = NULL; - return self; + return (BablModel*)self; } BablModel * @@ -91,7 +89,7 @@ babl_model_new (const char *name, { Babl *babl = (Babl*)arg; - switch (BABL_INSTANCE_TYPE (arg)) + switch (babl->class_type) { case BABL_COMPONENT: band_component [components] = (BablComponent*) babl; @@ -119,9 +117,10 @@ babl_model_new (const char *name, case BABL_CONVERSION_PIXEL_FORMAT: case BABL_CONVERSION_PIXEL_FORMAT_PLANAR: case BABL_FISH: + case BABL_FISH_REFERENCE: case BABL_IMAGE: babl_log ("%s(): %s unexpected", - __FUNCTION__, babl_class_name (babl->instance.type)); + __FUNCTION__, babl_class_name (babl->class_type)); break; case BABL_SKY: /* shut up compiler */ break; diff --git a/babl/babl-pixel-format.c b/babl/babl-pixel-format.c index 226125c..c84536c 100644 --- a/babl/babl-pixel-format.c +++ b/babl/babl-pixel-format.c @@ -52,33 +52,33 @@ pixel_format_new (const char *name, BablSampling **band_sampling, BablType **band_type) { - BablPixelFormat *self; + Babl *self; int band; self = babl_calloc (sizeof (BablPixelFormat), 1); - self->instance.type = BABL_PIXEL_FORMAT; + self->class_type = BABL_PIXEL_FORMAT; self->instance.id = id; self->instance.name = babl_strdup (name); - self->bands = bands; - self->planar = planar; + self->pixel_format.bands = bands; + self->pixel_format.planar = planar; - self->component = babl_malloc (sizeof (BablComponent*) * (bands+1)); - self->type = babl_malloc (sizeof (BablType*) * (bands+1)); - self->sampling = babl_malloc (sizeof (BablSampling*) * (bands+1)); + self->pixel_format.component = babl_malloc (sizeof (BablComponent*) * (bands+1)); + self->pixel_format.type = babl_malloc (sizeof (BablType*) * (bands+1)); + self->pixel_format.sampling = babl_malloc (sizeof (BablSampling*) * (bands+1)); for (band=0; band < bands; band++) { - self->component[band] = band_component[band]; - self->type[band] = band_type[band]; - self->sampling[band] = band_sampling[band]; + self->pixel_format.component[band] = band_component[band]; + self->pixel_format.type[band] = band_type[band]; + self->pixel_format.sampling[band] = band_sampling[band]; } - self->component[band] = NULL; - self->type[band] = NULL; - self->sampling[band] = NULL; + self->pixel_format.component[band] = NULL; + self->pixel_format.type[band] = NULL; + self->pixel_format.sampling[band] = NULL; - return self; + return (BablPixelFormat*)self; } BablPixelFormat * @@ -112,7 +112,7 @@ babl_pixel_format_new (const char *name, { Babl *babl = (Babl*)arg; - switch (BABL_INSTANCE_TYPE (arg)) + switch (babl->class_type) { case BABL_TYPE: current_type = (BablType*) babl; @@ -135,7 +135,7 @@ babl_pixel_format_new (const char *name, case BABL_INSTANCE: case BABL_MODEL: babl_log ("%s(): %s not handled in pixel format yet", - __FUNCTION__, babl_class_name (babl->instance.type)); + __FUNCTION__, babl_class_name (babl->class_type)); break; case BABL_PIXEL_FORMAT: @@ -146,9 +146,10 @@ babl_pixel_format_new (const char *name, case BABL_CONVERSION_PIXEL_FORMAT: case BABL_CONVERSION_PIXEL_FORMAT_PLANAR: case BABL_FISH: + case BABL_FISH_REFERENCE: case BABL_IMAGE: babl_log ("%s(): %s unexpected", - __FUNCTION__, babl_class_name (babl->instance.type)); + __FUNCTION__, babl_class_name (babl->class_type)); break; case BABL_SKY: /* shut up compiler */ break; diff --git a/babl/babl-sampling.c b/babl/babl-sampling.c index 567f0c6..7bd2f86 100644 --- a/babl/babl-sampling.c +++ b/babl/babl-sampling.c @@ -85,7 +85,7 @@ babl_sampling_init (void) for (vertical=VERTICAL_MIN; vertical<=VERTICAL_MAX; vertical++) { int index= (vertical-VERTICAL_MIN) * VERTICAL_MAX + (horizontal - HORIZONTAL_MIN); - db[index].instance.type = BABL_SAMPLING; + db[index].instance.class_type = BABL_SAMPLING; db[index].instance.id = 0; db[index].instance.name = "Samplings have no name"; db[index].horizontal = horizontal; diff --git a/babl/babl-sanity.c b/babl/babl-sanity.c index 4075bda..db58dc8 100644 --- a/babl/babl-sanity.c +++ b/babl/babl-sanity.c @@ -141,7 +141,7 @@ id_sanity (Babl *babl, if (0 == babl->instance.id) { babl_log ("%s\t'%s' has id==0", - babl_class_name (babl->instance.type), babl->instance.name); + babl_class_name (babl->class_type), babl->instance.name); } return 0; } diff --git a/babl/babl-type.c b/babl/babl-type.c index ba1ff8e..211733d 100644 --- a/babl/babl-type.c +++ b/babl/babl-type.c @@ -20,7 +20,6 @@ #include "babl-internal.h" #include "babl-db.h" - #include #include @@ -41,15 +40,15 @@ type_new (const char *name, int id, int bits) { - BablType *self; + Babl *self; self = babl_calloc (sizeof (BablType), 1); - self->instance.type = BABL_TYPE; + self->class_type = BABL_TYPE; self->instance.id = id; self->instance.name = babl_strdup (name); - self->bits = bits; + self->type.bits = bits; - return self; + return (BablType*)self; } BablType * @@ -75,28 +74,8 @@ babl_type_new (const char *name, { Babl *babl = (Babl*)arg; - switch (BABL_INSTANCE_TYPE (arg)) - { - case BABL_TYPE: - case BABL_INSTANCE: - case BABL_COMPONENT: - case BABL_MODEL: - case BABL_PIXEL_FORMAT: - case BABL_SAMPLING: - - case BABL_CONVERSION: - case BABL_CONVERSION_TYPE: - case BABL_CONVERSION_TYPE_PLANAR: - case BABL_CONVERSION_MODEL_PLANAR: - case BABL_CONVERSION_PIXEL_FORMAT: - case BABL_CONVERSION_PIXEL_FORMAT_PLANAR: - case BABL_FISH: - babl_log ("%s(): %s unexpected", - __FUNCTION__, babl_class_name (babl->instance.type)); - break; - case BABL_SKY: /* shut up compiler */ - break; - } + babl_log ("%s(): %s unexpected", + __FUNCTION__, babl_class_name (babl->class_type)); } /* if we didn't point to a babl, we assume arguments to be strings */ else if (!strcmp (arg, "id")) diff --git a/tests/Makefile.am b/tests/Makefile.am index 3be1ce5..1ad19d8 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -14,3 +14,5 @@ nop_LDADD = $(top_builddir)/babl/libbabl.la EXTRA_DIST= \ .cvsignore + +TESTS=nop introspect -- 2.30.2